/** @file vector2.cpp
  *
  * Funkcje skladowe klasy Vector2.
  */

#include "vector2.h"

using namespace std;

/// Operatory.

const Vector2 operator+(const Vector2 &a, const Vector2 &b) {
	return Vector2(a.x+b.x, a.y+b.y);
}

const Vector2 operator-(const Vector2 &a, const Vector2 &b) {
	return Vector2(a.x-b.x, a.y-b.y);
}

const Vector2 operator*(const Vector2 &a, const float &b) {
	return Vector2(a.x*b, a.y*b);
}

const Vector2 operator/(const Vector2 &a, const float &b) {
	return Vector2(a.x/b, a.y/b);
}

Vector2& operator+=(Vector2 &a, const Vector2 &b) {
	a.x += b.x;
	a.y += b.y;
	return a;
}

Vector2& operator-=(Vector2 &a, const Vector2 &b) {
	a.x -= b.x;
	a.y -= b.y;
	return a;
}

Vector2& operator*=(Vector2 &a, const float &b) {
	a.x *= b;
	a.y *= b;
	return a;
}

bool operator==(Vector2 &a, const Vector2 &b) {
  if ((a.x == b.x) && (a.y == b.y)) return true;
  return false;
}

Vector2& operator/=(Vector2 &a, const float &b) {
	a.x /= b;
	a.y /= b;
	return a;
}

ofstream& operator<<(ofstream &o, const Vector2 &a) {
	o << "x: " << a.x << ", y: " << a.y << endl;
	return o;
}

/** @fn const float dist(const Vector2 &a, const Vector2 &b)
  * @param a Pierwszy wektor
  * @param b Drugi wektor
  * @return Odleglosc wektora miedzy koncami wektorow
  *
  */
const float dist(const Vector2 &a, const Vector2 &b) {

	return sqrt(pow(a.x - b.x, 2)+pow(a.y - b.y, 2));
}

/** @fn float dist(const Vector2 &a, const Vector2 &b)
  * @param a Pierwszy wektor
  * @param b Drugi wektor
  * @return Iloczyn skalarany wektorow a i b
  *
  */
const float dotp(const Vector2 &a, const Vector2 &b) {
  return a.x*b.x + a.y*b.y;
}

/*
const float dist(const Vector2 &a, const float &x, const float &y){
	return std::sqrt(std::pow(a.x-x,2)+std::pow(a.y-y,2));
}*/

